package org.niux.aims.action.ajax;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.niux.aims.common.web.AimsBaseAction;
import org.niux.aims.service.IApplicationService;
import org.niux.aims.vo.ApplicationVO;

/**
 * 
 * Copyright (c) 2009,niux<br>
 * All rights reserved.<br>
 * 
 * 文件名称：GetAppsAjax.java<br>
 * 摘    要：获取应用数据AJAX类<br>
 * <br>
 * 当前版本：<br>
 * 作    者：铭显 Email: <a href="mailto:liangmingxian@gmail.com">liangmingxian@gmail.com</a><br>
 * 完成日期：@since 2013-8-1<br>
 * <br>
 * 取代版本：<br>
 * 原作者  ：<br>
 * 完成日期：@since Oct 22, 2009<br>
 */
public class GetAppsAjax extends AimsBaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3684244400354601136L;
	
	private Log log = LogFactory.getLog(this.getClass());
	private int page;
	private int pageSize;
	private List<ApplicationVO> apps;
	
	@Resource(name="applicationService")
	private IApplicationService applicationService;
	
	public GetAppsAjax() {
		this.apps = new ArrayList<ApplicationVO>();
	}

	/**
	 * 
	 * 方法概述：分页获取应用数据
	 * 描述：分页获取应用数据
	 * @return
	 * 返回类型：String
	 * 修改人：梁铭显
	 * 修改时间：2013-8-1
	 */
	public String getAppsByPage(){
		log.debug(page + "====" + pageSize);
		apps.clear();
		
		int startPage = page * pageSize;
		
		apps = applicationService.findByPage(startPage, pageSize);
		
		return SUCCESS;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List<ApplicationVO> getApps() {
		return apps;
	}

	public void setApps(List<ApplicationVO> apps) {
		this.apps = apps;
	}
}
